new Vue({
    el: '#app',
    data() {
      return {
        column:'',
        store:[],
        shop:[],
        form: {
            Integral_Unit_Price_SerialNumber: "",
            Start_Date: "",
            End_Date: "",
            Children: {
              integral_unitprice_detail: [
                {
                  Integral_Unit_Price_Detail_SerialNumber: "",
                  Integral_Unit_Price_SerialNumber: "",
                  Article_SerialNumber: "",
                  Article_Specifications_SerialNumber: "",
                  Unit_Price: "",
                  Integral_Unit_Price: "",
                  Sign: "无货货主",
                  specs: [],//商品规格
                  Distribute: '',
                  Warehouse: [],
                  sWarehouse: [],
                  Children: {
                    integral_unitprice_stock: [
                    ]
                  }
                }
              ],
              integral_scheme_storescope: [
                {
                  Integral_Unit_Price_StoreScope_SerialNumber: "",
                  Integral_Unit_Price_SerialNumber: "",
                  Store_SerialNumber: "",
                }
              ],
            }
        },
      }
    },
    mounted() {
      const Integral_Unit_Price_SerialNumber = sessionStorage.getItem("Integral_Unit_Price_SerialNumber")
      this.getData(Integral_Unit_Price_SerialNumber)
    },
    methods: {
      getData(Integral_Unit_Price_SerialNumber) {
        const _this = this
        $.ajax({
          url: DomainName + '/SalesUnitprice_Edit',
          type: 'POST',
          data: { Data: Integral_Unit_Price_SerialNumber ,token:$.cookie("token") },
          async:false,
          success: function (res) {
            console.log(res);
            _this.form = res.sales_unitprice[0]
            if (!_this.form.Children.integral_unitprice_detail || _this.form.Children.integral_unitprice_detail.length == 0) {
              _this.form.Children.integral_unitprice_detail = [{
                Integral_Unit_Price_Detail_SerialNumber: '',
                Integral_Unit_Price_SerialNumber: this.form.Integral_Unit_Price_SerialNumber,
                Article_SerialNumber: '',
                Unit_Price: '',
                Sales_Unit_Price: '',
                Row_Status: '',
                Operation_ID: '',
                Operation_Datetime: '',
              }]
            }
            if (!_this.form.Children.sales_unitprice_storescope || _this.form.Children.sales_unitprice_storescope.length == 0) {
              _this.form.Children.sales_unitprice_storescope = [{
                Sales_Unit_Price_StoreScope_SerialNumber: '',
                Integral_Unit_Price_SerialNumber:this.form.Integral_Unit_Price_SerialNumber,
                Store_SerialNumber: '',
                Row_Status: '',
                Operation_ID: '',
                Operation_Datetime: '',
              }]
            }
          }
        })
        $.ajax({
          url: DomainName + '/StoreInfo',
          type: 'GET',
          data: { action: "jQueryAjax" },
          success: function (res) {
            for (let i = 0; i < _this.form.Children.sales_unitprice_storescope.length; i++) {
              for (let j = 0; j < res.length; j++) {
                if (_this.form.Children.sales_unitprice_storescope[i].Store_SerialNumber == res[j].Store_SerialNumber) {
                  _this.store.push(res[j].Store_Name);
                }
              }
            }
          }
        })
        $.ajax({
          url: DomainName + '/ShopColumn',
          type: 'GET',
          data: { action: "jQueryAjax" },
          success: function (res) {
            res = res.filter(function (item) {
              return item.ShopColumn_Id == _this.form.ShopColumn_Id
            })
            _this.column = res[0].name;
          }
        })
        $.ajax({
          url: DomainName + '/ArticleInfo',
          type: 'GET',
          data: { action: "jQueryAjax" },
          success: function (res) {
            for (let i = 0; i < _this.form.Children.integral_unitprice_detail.length; i++) {
              for (let j = 0; j < res.length; j++) {
                if (_this.form.Children.integral_unitprice_detail[i].Article_SerialNumber == res[j].Article_SerialNumber) {
                  _this.shop.push(res[j].Article_Name);
                }
              }
            }
          }
        })
      }
    }
  })